package com.prognos.service.impl;

import com.prognos.domain.info.InfoSource;
import com.prognos.persistence.dao.InfoSourceDao;
import com.prognos.service.InfoSourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by chema on 10/12/14.
 */
@Service("InfoSourceService")
public class InfoSourceServiceImpl implements InfoSourceService {

    private final InfoSourceDao infoSourceDao;

    @Autowired
    public InfoSourceServiceImpl(InfoSourceDao infoSourceDao) {
        this.infoSourceDao = infoSourceDao;
    }

    @Override
    public boolean urlExists(String url) {
        InfoSource infoSource = infoSourceDao.findByUrl(url);
        return infoSource != null;
    }

    @Override
    public void create(InfoSource is) {
        infoSourceDao.saveOrUpdate(is);
    }
}
